package top.tomxwd.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.tomxwd.service.PaymentService;

/**
 * @author xieweidu
 * @createDate 2020-08-02 18:20
 */
@RestController
@Slf4j
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @RequestMapping("/ok/{id}")
    public String paymentInfoOk(@PathVariable("id") Integer id) {
        String s = paymentService.paymentInfoOk(id);
        log.info("结果：" + s);
        return s;
    }

    @RequestMapping("/timeout/{id}")
    public String paymentInfoTimeout(@PathVariable("id") Integer id) {
        String s = paymentService.paymentInfoTimeout(id);
        log.info("结果：" + s);
        return s;
    }

    @RequestMapping("/{id}")
    public String payment(@PathVariable("id") Integer id) {
        return paymentService.paymentCircuitBreaker(id);
    }

}
